"use strict";
require(["sideNav"], function () {
    var $leftNav = $(".side-menu");
    var app = {
        init: function () {
            var menudata = [
                {
                    id: "1",
                    name: "项目管理",
                    url: "",
                    ico: "aidicon aidicon-cube-outline",
                    parentId: "backstage",
                    child: [
                        {
                            id: "11",
                            name: "项目信息",
                            url: "projectInfo.html",
                            parentId: "1"
                        },
                        {
                            id: "12",
                            name: "设备组管理",
                            url: "equipmentInfo.html",
                            parentId: "1"
                        },
                        {
                            id: "13",
                            name: "点位管理",
                            url: "positionInfo.html",
                            parentId: "1"
                        }
                    ]
                },
                {
                    id: "2",
                    name: "网关管理",
                    url: "gatewayInfo.html",
                    ico: "aidicon aidicon-office",
                    parentId: "backstage"
                },
                {
                    id: "3",
                    name: "用户管理",
                    url: "userInfo.html",
                    ico: "aidicon aidicon-account-edit",
                    parentId: "backstage"
                },
                {
                    id: "4",
                    name: "权限管理",
                    url: "authorityInfo.html",
                    ico: "aidicon aidicon-clipboard-text",
                    parentId: "backstage",
                },
                {
                    id: "5",
                    name: "平台配置",
                    url: "",
                    ico: "aidicon aidicon-laptop-mac",
                    parentId: "backstage",
                    child: [
                        {
                            id: "51",
                            name: "全局配置",
                            url: "globalConfig.html",
                            parentId: "5"
                        },
                        {
                            id: "52",
                            name: "项目配置",
                            url: "projectConfig.html",
                            parentId: "5"
                        },
                        {
                            id: "53",
                            name: "保养信息",
                            url: "maintainInfo.html",
                            parentId: "5"
                        },
                        {
                            id: "54",
                            name: "单位管理",
                            url: "unit.html",
                            parentId: "5"
                        },
                        {
                            id: "55",
                            name: "设备类型管理",
                            url: "equipmentType.html",
                            parentId: "5"
                        }
                        ,{
                            id:"56",
                            name:"设备保养管理",
                            url:"equipmentMaintain.html",
                            parentId:"5"
                        }
                    ]
                }
            ];

            //初始化导航
            $leftNav.sideNav({
                theme: 0, //默认主题
                syslogo: '<i class="aidicon aidicon-web"></i>',
                sysName: "盛世机电数据中心",
                size: "normal", //normal|small|top
                currentValue: sessionStorage.getItem("menuId") ? sessionStorage.getItem("menuId") : "11", //初始化选中的值
                data: menudata,
                systemId: "backstage"
            });

            //组件选中完成回调事件
            $leftNav.on("done.bs", function (e, data) {
                sessionStorage.setItem("menuId", data.id);
                sessionStorage.setItem("title", data.name);
                // skip(data.url);
                window.open(data.url, "_self");
            });

            //组件进行大小切换完成后回调事件
            $leftNav.on("resize.bs", function (e) {
                console.log("现在状态", e.sizeStatus);
                $(".cs-page-nav").css("width", "auto");
            });

            $(".title-text").text((sessionStorage.getItem("title") ? sessionStorage.getItem("title") : "项目信息"));

            // 导航展开收起
            $(document).on("click", ".header-content .aidicon", function () {
                var $this = $(this);
                $(".side-menu").toggleClass("fold");
                if($(".side-menu").hasClass("fold")) {
                    $this.removeClass("aidicon-backburger").addClass("aidicon-menu");
                } else {
                    $this.removeClass("aidicon-menu").addClass("aidicon-backburger");
                }
                
            })
            $(document).on("click", ".sideNav-head", function () {
                window.location.href = "../system/main.html"
            })
        }
    };
    app.init();
});